#import "RNCatalog.h"
#import "RNConstants.h"

static RNCatalog *sharedCatalog = nil;

@implementation RNCatalog

@synthesize icon = icon_;

+(RNCatalog *)sharedCatalog {
    if (!sharedCatalog)
        sharedCatalog = [[RNCatalog alloc] init];
    return sharedCatalog;
}

-(id)init {
    if (!(self = [super init]))
        return nil;
    
    [self setIcon:[NSImage imageNamed:@"sourceList_catalog.png"]];
    return self;
}

-(NSString *)title {
    return @"Catalog";
}

-(NSArray *)children {
    return nil;
}

-(id)parent {
    return nil;
}

-(NSDictionary *)objectDictionary {
    NSMutableDictionary *objectDictionary = [NSMutableDictionary dictionary];
    [objectDictionary setValue:[self title] forKey:RNTitleKey];
    [objectDictionary setValue:[self icon] forKey:@"icon"];
    return objectDictionary;
}

-(BOOL)canContainObjectsWithEntityNames:(NSArray *)entityNames {
    NSArray *validObjects = [entityNames filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self LIKE %@", RNEntityNameCategory]];
    return [validObjects count] == [entityNames count];
}

@end
